package com.yc.ioc.test.bean3.Factory;

import com.yc.ioc.test.bean3.other.Fruit;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class App_FactoryBean {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(App_FactoryBean.class);
        //要获取工厂对象，必须使用&符号
        FruitFactoryBean ffb = (FruitFactoryBean) ac.getBean("&ffb");
        System.out.println(ffb.hashCode());
        Fruit fruit = (Fruit) ac.getBean("ffb");
        System.out.println(fruit);

    }
    @Bean
    public FruitFactoryBean ffb(){
        return new FruitFactoryBean();
    }
}
